// pages/shop/shop.js
const App = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    previewImages: [],
    detailImages: [],
    navH: 0,
    title: null,
    groupPrice: null,
    alonePrice: null,
    shop: null,
    shopUrl: null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.setData({
      navH: App.globalData.navHeight,
      title: App.globalData.productInfor[App.globalData.productIndex].productName,
      groupPrice: App.globalData.productInfor[App.globalData.productIndex].productGroupPrice,
      alonePrice: App.globalData.productInfor[App.globalData.productIndex].productAlonePrice,
      shop: App.globalData.productInfor[App.globalData.productIndex].shop,
      shopUrl: App.globalData.productInfor[App.globalData.productIndex].shopUrl
    })
    var that = this
    wx.request({
      url: 'http://localhost:8081/getproductimg/' + App.globalData.productInfor[App.globalData.productIndex].productName,
      success(res) {
        that.setData({
          previewImages:res.data
        })
      }
    })
    wx.request({
      url: 'http://localhost:8081/getproductdetail/' + App.globalData.productInfor[App.globalData.productIndex].productName,
      success(res) {
        that.setData({
          detailImages: res.data
        })
      }
    })
  },

  goBack: function() {
    wx.navigateBack({
      delta: 1
    })
  },
  
  goBuy: function(){
    wx.navigateTo({
      url: '../pay/pay',
    })
    App.globalData.whichOne='alonePrice'
  },

  goBuy1: function () {
    wx.navigateTo({
      url: '../pay/pay',
    })
    App.globalData.whichOne = 'groupPrice'
  }
})